package com.googlecode.websecuritychecks;

import java.util.*;

import javax.servlet.http.HttpServletRequest;

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class ParameterValueCheck extends RegexBasedCheck {

    @Override
    protected List<String> getValuesToBeChecked(final HttpServletRequest httpServletRequest) {

        List<String> values = new ArrayList<>();
        for (Map.Entry<String, String[]> entry : httpServletRequest.getParameterMap().entrySet()) {
            for (String value : entry.getValue()) {
                values.add(value);
            }
        }
        return values;
    }

    @Override
    protected NodeList getRuleXmlNodeList(final Element ruleXmlElementFragment) {
        return ruleXmlElementFragment.getElementsByTagName("InvalidParameterValueCheck");
    }

}
